package com.offcn.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.offcn.user.dao.AddressMapper;
import com.offcn.user.pojo.Address;
import com.offcn.user.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AddressServiceImpl implements AddressService {

    @Autowired(required = false)
    private AddressMapper addressMapper;

    @Override
    public List<Address> findAddressListByUsername(String username) {
        QueryWrapper<Address> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("user_id",username);
        return addressMapper.selectList(queryWrapper);
    }

    @Override
    public void saveAddress(Address address) {
        addressMapper.insert(address);
    }

    @Override
    public void updateAddress(Address address) {
        addressMapper.updateById(address);
    }
}
